package org.example.controller;

import io.swagger.annotations.Api;
import org.example.annotation.mySystemlog;
import org.example.canstants.SystemCanstants;
import org.example.domain.entity.Comment;
import org.example.domain.result.ResponseResult;
import org.example.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment")
@Api(tags = "评论接口")
public class CommentController {
    @Autowired
    private CommentService commentService;

    @GetMapping("/commentList")
    @mySystemlog(businessName = "获取文章评论列表")
    public ResponseResult commentList(Long articleId,Integer pageNum,Integer pageSize){
        return commentService.commentList(SystemCanstants.ARTICLE_COMMENT,articleId,pageNum,pageSize);
    }

    @PostMapping
    @mySystemlog(businessName = "发送评论")
    public ResponseResult addComment(@RequestBody Comment comment){
        return commentService.addComment(comment);
    }

    @GetMapping ("/linkCommentList")
    @mySystemlog(businessName = "获取友链评论列表")
    public ResponseResult LinkCommentList(Integer pageNum,Integer pageSize){
        return commentService.commentList(SystemCanstants.LINK_COMMENT,null,pageNum,pageSize);
    }

    // 删除评论（逻辑删除）
    @DeleteMapping("/{id}")
    public ResponseResult deleteComment(@PathVariable Long id) {
        return commentService.deleteComment(id);
    }

    // 更新评论
    @PutMapping("/{id}")
    public ResponseResult updateComment(@PathVariable Long id, @RequestBody Comment comment) {
        return commentService.updateComment(id, comment);
    }


}
